<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <style>
        .tabs{}
        .tabs li{float:left;background-color:#f4f4f4;border-left:1px solid #e2e2e2;border-top:1px solid #ddd;border-right:1px solid #ddd;margin-right:0px;}
        .tabs li a{color:#555555;float:left;text-decoration:none;padding:5px 12px;}
        .tabs li a:link,.tabs li a:visited,.tabs li a:hover,.tabs li a:active{text-decoration:none;}
        .tabs li.active{background-color:#FFFFFF;border-left:1px solid #ddd;border-top:1px solid #ddd;border-right:1px solid #ddd;}
        .tabs li.active a{color:#fff;background:#ed5565;border-color:#ed5565;}
        .tabs li.hover{background-color:#e7e7e7;border-left:1px solid #ddd;border-top:1px solid #ddd;border-right:1px solid #ddd;}
        .tabs li.hover a{color:#000;}
    </style>
    <script>
      $(function() {
        $("#radio").buttonset();
        $("#sortHead").headSort();
        $("#tabs li").each(function(){
          $(this).hover(function(){
            if(!$(this).hasClass("active")) {
              $(this).addClass("hover");
            }
          },function(){
            $(this).removeClass("hover");
          });
        });
        if('${init}'=="0"){
          $("#queryBtn").click();
        }
      });
      function confirmDelete() {
        return confirm("<s:message code='confirmDelete'/>");
      }
      function optSingle(opt) {
        if(Cms.checkeds("ids")==0) {
          alert("<s:message code='pleaseSelectRecord'/>");
          return false;
        }
        if(Cms.checkeds("ids")>1) {
          alert("<s:message code='pleaseSelectOne'/>");
          return false;
        }
        var id = $("input[name='ids']:checkbox:checked").val();
        var url = $(opt+id).attr("href");
        if(url) {
          location.href=$(opt+id).attr("href");
        } else {
          alert("<s:message code='noPermission'/>");
        }
      }
      function optMulti(form, action, confirmMsg) {
        if(Cms.checkeds("ids")==0) {
          alert("<s:message code='pleaseSelectRecord'/>");
          return false;
        }
        if(confirmMsg) {
          if($.isFunction(confirmMsg)) {
            if(!confirmMsg()) {
              return false;
            }
          } else {
            if(!confirm(confirmMsg)) {
              return false;
            }
          }
        }
        form.action=action;
        form.submit();
        return true;
      }
      function optDelete(form) {
        if(Cms.checkeds("ids")==0) {
          alert("<s:message code='pleaseSelectRecord'/>");
          return false;
        }
        if(!confirmDelete()) {
          return false;
        }
        form.action='anchordelete.do';
        form.submit();
        return true;
      }
      //刷新
      function optReload() {
        var form=$("#searchForm");
        form.submit();
        return true;
      }
      <c:if test="${!empty refreshLeft}">
      parent.frames["left"].location.href="left.do";
      </c:if>

      function  updateDynamicSelect(dynamicId) {
        if (dynamicId == '' || dynamicId == null) {
          return false;
        }
        var select = $("#select_" + dynamicId).val();
        var data = {};
        data.dynamicId =dynamicId;
        data.select = select;
        var url = CMSCP + '/core/pub_center/updateDynamicSelect.do';
        $.ajax({
          type: "POST",
          url: url,
          dataType: "json",
          data: data,
          async: false,
          success: function (msg) {
            if (msg.msg == 'success') {
              alert('修改成功！');
            } else {
              alert('参数错误，请刷新重试！');
            }

          },
          error: function (msg) {
            alert("系统异常！");
          }
        });
      }
    </script>
</head>
<body class="skin-blue content-body">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1>主播动态 - <s:message code="list"/> <small>(<s:message code="totalElements" arguments="${pagedList.totalElements}"/>)</small></h1>
</div>
<div class="content">
    <div class="box box-primary">
        <div class="box-body table-responsive">
            <form id="searchForm" action="dynamiclnfolist.do" method="get" class="form-inline ls-search">
                <div class="form-group">
                    <label for="search_CONTAIN_detail.title"><s:message code="info.title"/></label>
                    <input class="form-control input-sm" type="text" id="search_CONTAIN_detail.title" name="search_CONTAIN_detail.title" value="${requestScope['search_CONTAIN_detail.title'][0]}" style="width:150px;"/>
                </div>

                <button class="btn btn-default btn-sm" id="queryBtn" type="submit"><s:message code="search"/></button>
                <f:hidden name="queryParentId" value="${queryParentId}"/>
                <f:hidden name="queryNodeType" value="${queryNodeType}"/>
                <f:hidden id="queryStatus" name="queryStatus" value="${queryStatus}"/>
            </form>
            <form method="post">
                <tags:search_params/>
                <f:hidden name="queryParentId" value="${queryParentId}"/>
                <f:hidden name="queryNodeId" value="${queryParentId}"/>
                <f:hidden name="queryNodeType" value="${queryNodeType}"/>
                <f:hidden name="queryInfoPermType" value="${queryInfoPermType}"/>
                <f:hidden name="queryStatus" value="${queryStatus}"/>
                <f:hidden name="returnUrl" value="dynamiclnfolist"/>
                <div class="btn-toolbar ls-btn-bar">
                    <%--<div class="btn-group">--%>
                    <%--<shiro:hasPermission name="core:publish_center:create">--%>
                    <%--&lt;%&ndash;<button class="btn btn-default" type="button" onclick="location.href='create.do?queryNodeId=${queryNodeId}&queryNodeType=${queryNodeType}&queryInfoPermType=${queryInfoPermType}&queryStatus=${queryStatus}&${searchstring}';"><s:message code="create"/></button>&ndash;%&gt;--%>
                    <%--<button class="btn btn-default" type="button" onclick="location.href='anchorcreate.do?parentId=${parent.id}&queryParentId=${queryParentId}&showDescendants=${showDescendants}&${searchstring}';">新建资讯</button>--%>
                    <%--</shiro:hasPermission>--%>
                    <%--</div>--%>
                    <%--<div class="btn-group">--%>
                    <%--<shiro:hasPermission name="core:info:create">--%>
                    <%--<button class="btn btn-default" type="button" onclick="return optDelete(this.form);">添加专题</button>--%>
                    <%--</shiro:hasPermission>--%>
                    <%--</div>--%>
                    <%--<div class="btn-group">--%>
                    <%--<shiro:hasPermission name="core:info:create">--%>
                    <%--<button class="btn btn-default" type="button" onclick="return optMulti(this.form,'infologic_delete.do',confirmDelete);"><s:message code="delete"/></button>--%>
                    <%--</shiro:hasPermission>--%>
                    <%--</div>--%>
                    <div class="btn-group">
                        <button class="btn btn-default" type="button" onclick="return optReload(this.form);">刷新</button>
                    </div>
                    <shiro:hasPermission name="core:info:audit_pass">
                        <button class="btn btn-default" type="button" onclick="return optMulti(this.form,'dynamicauditPass.do');"><s:message code="info.auditPass"/></button>
                    </shiro:hasPermission>
                    <%--<div class="btn-group">--%>
                        <%--<button class="btn btn-default" type="button" onclick="location.href='/cmscp/core/generation/generationDataByNode.do?returnUrl=/cmscp/core/pub_center/dynamiclnfolist&queryNodeId=${queryParentId}';">生成</button>--%>
                    <%--</div>--%>

                </div>

                <table id="pagedTable" class="table table-condensed table-bordered table-hover ls-tb">
                    <thead id="sortHead" pagesort="<c:out value='${page_sort[0]}' />" pagedir="">
                    <tr class="ls_table_th">
                        <th width="25"><input type="checkbox" onclick="Cms.check('ids',this.checked);"/></th>
                        <th width="30" class="ls-th-sort"><span class="ls-sort" pagesort="id">ID</span></th>
                        <%--<th width="60" class="ls-th-sort"><span class="ls-sort" pagesort="id">预览</span></th>--%>
                        <th class="ls-th-sort"><span class="ls-sort" >动态内容</span></th>
                        <th class="ls-th-sort"><span class="ls-sort" >是否精选</span></th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="publishDate">创建时间</span></th>
                        <th class="ls-th-sort"><span class="ls-sort" >状态</span></th>
                        <th class="ls-th-sort"><span class="ls-sort" >点赞数</span></th>
                        <th width="180">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="bean" varStatus="status" items="${pagedList.content}">
                        <tr>
                            <td><input type="checkbox" name="ids" value="${bean.id}"/></td>
                            <td align="center"><c:out value="${bean.id}"/></td>
                                <%--<td align="center"><c:out value="预览"/></td>--%>
                            <td align="center">
                                <div><a href="javascript:void(0);" title="<c:out value='${bean.title}'/>"><c:out value="${fnx:substringx_sis(bean.title,30,'...')}"/></a></div>
                            </td>
                            <td align="center">
                                <select class="form-control" id="select_${bean.id}" name="select" onchange="updateDynamicSelect('${bean.id}')" <shiro:lacksPermission name="core:info:updateDynamicSelect">disabled="disabled"</shiro:lacksPermission> >
                                    <f:option value="0" selected="${bean.select}">是</f:option>
                                    <f:option value="1" selected="${bean.select}">否</f:option>
                                </select>

                            </td>
                                <%--<td align="center">--%>
                                <%--<div>--%>
                                <%--<span style="color:blue;"><c:out value="${bean.detail.title}"/></span>--%>
                                <%--</div>--%>
                                <%--</td>--%>
                            <td align="center">
                                <div><fmt:formatDate value="${bean.publishDate}" pattern="yyyy-MM-dd HH:mm:ss"/></div>
                            </td>
                            <td align="center">
                                <div>
                                    <c:choose>
                                        <c:when test="${bean.status eq '1'}">
                                            ${bean.stepName}
                                        </c:when>
                                        <c:when test="${bean.status eq 'A'}">
                                            <a href="javascript:void(0);" ><s:message code="info.status.${bean.status}"/></a>
                                        </c:when>
                                        <c:otherwise>
                                            <s:message code="info.status.${bean.status}"/>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </td>
                            <td align="center"><c:out value="${bean.bufferDiggs}"/></td>
                            <td align="center">
                                    <%--<a href="infologic_delete.do?returnUrl=dynamiclnfolist&ids=${bean.id}&queryNodeId=${queryParentId}&queryNodeType=${queryNodeType}&queryInfoPermType=${queryInfoPermType}&queryStatus=${queryStatus}&${searchstring}" onclick="return confirmDelete();" class="ls-opt"><s:message code="delete"/></a>--%>
                                <a id="edit_opt_${bean.id}" href="infoedit.do?returnUrl=core/publish_center/dynamic_form&id=${bean.id}&position=${pagedList.number*pagedList.size+status.index}&queryParentId=${queryParentId}&${searchstring}" class="ls-opt">预览审核</a>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <c:if test="${fn:length(pagedList.content) le 0}">
                    <div class="ls-norecord"><s:message code="recordNotFound"/></div>
                </c:if>
            </form>
            <form action="dynamiclnfolist.do" method="get" class="ls-page">
                <tags:search_params excludePage="true"/>
                <f:hidden name="queryParentId" value="${queryParentId}"/>
                <f:hidden name="queryNodeType" value="${queryNodeType}"/>
                <f:hidden name="queryInfoPermType" value="${queryInfoPermType}"/>
                <f:hidden name="queryStatus" value="${queryStatus}"/>
                <f:hidden name="returnUrl" value="dynamiclnfolist"/>
                <tags:pagination pagedList="${pagedList}"/>
            </form>
        </div>
    </div>
</div>
</body>
</html>